﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Training9
{
    public partial class frmCourseTypeAdd : Form
    {
        public frmCourseTypeAdd()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlOperate obj = new SqlOperate();
            string strSql = "insert into T_CourseType(courseTypeID,courseTypeName) values('" + textBox1.Text + "','" + textBox2.Text + "')";
            if (obj.RunSql(strSql) > 0)
            {
                MessageBox.Show("添加记录成功！", "信息提示", MessageBoxButtons.OK);
                DataGridViewRow row = new DataGridViewRow();
                int index = dataGridView1.Rows.Add(row);
                dataGridView1.Rows[index].Cells[0].Value = textBox1.Text;
                dataGridView1.Rows[index].Cells[1].Value = textBox2.Text;
            }
            else
            { MessageBox.Show("添加记录失败！", "信息提示", MessageBoxButtons.OK); }
        }

        private void frmCourseTypeAdd_Load(object sender, EventArgs e)
        {

        }
    }
}
